package com.app.coffeephilosophy.adapter;

import java.util.ArrayList;
import java.util.List;

import com.app.coffeephilosophy.R;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.app.coffeephilosophy.modle.*;

public class SadAdapter extends BaseAdapter {
	private LayoutInflater inflater;
	private List<Picture> photolist;
	
	public SadAdapter(String[] textsad, int[] imagesSad,Context context) 
	{
		super();
		photolist = new ArrayList<Picture>();
		inflater = LayoutInflater.from(context);
		for (int i = 0; i < imagesSad.length; i++)
		{
			Picture picture = new Picture(textsad[i], imagesSad[i]);
			photolist.add(picture);
		}
		
	}

	 
	public int getCount() {
		// TODO Auto-generated method stub
		return photolist.size();
	}

	 
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return photolist.get(position);
	}

	 
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	 
	public View getView(int position, View convertView, ViewGroup parent)
	{
		ViewHolder viewHolder;
		if (convertView == null)
		{
			convertView = inflater.inflate(R.layout.gridview_item, null);
			viewHolder = new ViewHolder();
			viewHolder.title = (TextView) convertView.findViewById(R.id.title);
			viewHolder.image = (ImageView) convertView.findViewById(R.id.imageView);
			convertView.setTag(viewHolder);
		} else
		{
			viewHolder = (ViewHolder) convertView.getTag();
		}
		viewHolder.title.setText(photolist.get(position).getTitle());
		viewHolder.image.setImageResource(photolist.get(position).getImageId());
		return convertView;
	}

}
